package com.sendi.system.util.tree;

import java.util.ArrayList;
import java.util.HashSet;

import com.sendi.system.entity.Department;

public class DepartTreeNode extends TreeNode{

	public Department f;
	public ArrayList<Department> childpart;
	public HashSet<String> userids=new HashSet<String>();
	public ArrayList<DepartTreeNode> dchild;
	public void AddDChildNode(DepartTreeNode node) {
		 if(childpart==null)
		 {
			 childpart=new ArrayList<Department>();
			 dchild=new ArrayList<DepartTreeNode>();
		 }
		if(!childpart.contains(node.f))
		{
			childpart.add(node.f);
			dchild.add(node);
		}
		
		 
	}
  public void AdduserIds(ArrayList<String> userid)
  {
 	   if(userid!=null&&userid.size()>0)
	   {
		   userids.addAll(userid);
	   }
	  if(!this.isroot) 
	  {
		  ArrayList<String> alluserid=new ArrayList<String>();
		  alluserid.addAll(userids);
		 ((DepartTreeNode)this.parentNode).AdduserIds(alluserid);
 	  }
	
  }
  public boolean isPower(String userid)
  {
	 boolean re=false;
	 if(userid.equals("1"))return true; //超级管理员
     for(String a:userids)
     {
    	 if(a.equals(userid))
    	 {
    		 re=true;
    		 break;
    	 }
     }
     
     return re;
  }

}
